<template>
  <div class="header">
    <span class="sys-name">
      <div>社团管理系统后台</div>
    </span>
    <div class="right-menu">
      <el-dropdown>
        <span class="el-dropdown-link">
          <el-avatar :src="this.photo"></el-avatar>
          <span class="name">{{ this.username }}，你好</span>
        </span>
        <el-dropdown-menu style="">
          <el-dropdown-item>
            <router-link to="/ManagerInfo" class="no-underline"
              >个人信息</router-link
            >
          </el-dropdown-item>
          <el-dropdown-item>
            <router-link to="/AccountSetting" class="no-underline"
              >账号设置</router-link
            >
          </el-dropdown-item>
          <el-dropdown-item>
            <span @click="logout" class="logout">退出</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
// 获取token并解析
import router from '@/router'
import decodedToken from '@/api/tokenDecode'

export default {
  data() {
    return {
      username: decodedToken().claims.username,
      photo: decodedToken().claims.photo,
    }
  },
  methods: {
    logout() {
      //清空session
      localStorage.clear()
      router.push('/login')
    },
  },
}
</script>

<style scoped="scoped">
.header {
  position: fixed;
  top: 0;
  left: 200px;
  right: 0;
  height: 60px;
  background-color: #2f4056;
}
.header .sys-name {
  display: block;
  height: 60px;
  width: 250px;

  line-height: 60px;
  margin-left: 20px;
  color: white;
}
.header .sys-name a {
  color: #fff;
  text-decoration: none;
  font-size: 16px;
}

.right-menu {
  width: 300px;
  /*height: 55px;*/
  line-height: 60px;
  margin-top: -60px;
  float: right;
}
/*用户名*/
.right-menu .name {
  color: #eee;
}

.logout {
  cursor: pointer;
  margin-left: 30px;
}
/*头像*/
.el-avatar {
  margin-right: 20px;
  margin-top: 8px;
}
/* 去掉router-link下划线 */
.no-underline {
  text-decoration: none;
  color: inherit; /* 保持原本的文字颜色 */
}
</style>
